package dto

import (
	"github.com/gin-gonic/gin"
	"tino_manager/public"
)

// UserLoginAndRegister 微信用户登录和注册
type UserLoginAndRegister struct {
	Code      string `json:"code" form:"code" comment:"用户code" validate:"required"`
	PhoneCode string `json:"phone_code" form:"phone_code" comment:"手机号"`
	UserName  string `json:"user_name" form:"user_name"`
	HeadImage string `json:"head_image" form:"head_image"`
}

func (params *UserLoginAndRegister) BindValidParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, params)
}

type UserUpdateInput struct {
	Id        int64  `json:"id" form:"id" comment:"用户id" validate:"required"`
	UserName  string `json:"user_name" form:"user_name" comment:"用户昵称"`
	HeadImage string `json:"head_image" form:"head_image" comment:"用户头像"`
	Name      string `json:"name" form:"name" gorm:"column:name;comment:姓名"`
	Duties    string `json:"duties" form:"duties" gorm:"column:duties;comment:职务"`
	Phone     string `json:"phone" form:"phone" comment:"用户手机号"`
	DeptName  string `json:"dept_name" form:"dept_name" comment:"单位"`
}

func (params *UserUpdateInput) BindValidParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, params)
}

type UserPageInput struct {
	Type       string `json:"type" form:"type" comment:"查询类型"`
	KeyWord    string `json:"keyword" form:"keyword" comment:"搜索关键词"`
	PageSize   int    `json:"page_size" form:"page_size" comment:"每页数量" validate:"required,lte=20"`
	PageNumber int    `json:"page_number" form:"page_number" comment:"页码" validate:"required"`
}

func (params *UserPageInput) BindValidParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, params)
}

type UserInfo struct {
	Id            string `json:"id" gorm:"column:id;comment:自增id"`
	UserName      string `json:"user_name" gorm:"column:user_name;comment:用户名称"`
	OpenId        string `json:"open_id" gorm:"column:open_id;comment:小程序openId;unique;index;"`
	HeadImage     string `json:"head_image" gorm:"column:head_image;comment:用户头像"`
	MessageOpenId string `json:"message_open_id" gorm:"column:message_open_id;comment:消息提醒公众号openId"`
	Phone         string `json:"phone" gorm:"column:phone;comment:手机号;index;"`
	DeptName      string `json:"dept_name" form:"dept_name" comment:"单位"`
	Name          string `json:"name" form:"name" gorm:"column:name;comment:姓名"`
	Duties        string `json:"duties" form:"duties" gorm:"column:duties;comment:职务"`
	Status        uint8  `json:"status" gorm:"column:status;comment:0启用 1停用"`
	IsDelete      uint8  `json:"is_delete" gorm:"column:is_delete;comment:1已删除"`
	UpdatedAt     string `json:"update_at" gorm:"column:update_at;comment:更新时间"`
	CreatedAt     string `json:"create_at" gorm:"column:create_at;comment:创建时间"`
}
type UserPageOutput struct {
	List  []UserInfo `json:"list"`
	Total int64      `json:"total"`
}

type UserUpdateStatusInput struct {
	Id     string `json:"id" form:"id" comment:"用户id" validate:"required"`
	Status uint8  `json:"status" form:"status"`
}

func (params *UserUpdateStatusInput) BindValidParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, params)
}

type UserDetailInput struct {
	Id string `json:"id" form:"id"`
}

func (params *UserDetailInput) BindValidParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, params)
}

type GetMessageStatusInput struct {
	Code string `json:"code" form:"code" comment:"code" validate:"required"`
}

func (params *GetMessageStatusInput) BindValidParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, params)
}

type SwitchMessageInput struct {
	OpenMessageStatus uint8 `json:"open_message_status" form:"open_message_status" comment:"状态"`
}

func (params *SwitchMessageInput) BindValidParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, params)
}
